
/* this file is no longer used, can be removed CTC */

/*
function _getAmzElementsByXPath(expression,parent) {
    var results = [];
    var query = parent.evaluate(expression, parent || window.content.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0, length = query.snapshotLength; i < length; i++)
        results.push(query.snapshotItem(i));
    return results;
};
function getAmzElementsByClassName(className,parent) {
    var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
    return _getAmzElementsByXPath(q,parent);
}

function queryAmazonExternal() {
	var keyword = '';
	var product = swaksmack.SmackShopDoc.getElementById('productNameAnchor');
	if (product != null) {
 		keyword = product.textContent;
	}
	var aurl = "http://www.amazon.com/exec/obidos/external-search?mode=blended&keyword=" + keyword;
	Swak_openUrl(aurl,false);
}


function SwakAmazonProductInfo() {
	this.prodURL = null;
	this.prodPrice = null;
}


function AmazonProductRequest(product){
	//alert('APR create');
	this.product = product;
	
	//result url from tinurl
	this.amazonPriceResult = null;
	
	this.amazonInfoList = null;
	
	//amazon httprequest
	this.request = null;
	
	//execute the tiny url request
	this.execute = function(callback){
		
		// No need to shrink
		if(this.amazonPriceResult != null){
			return;
		}
		
		// check if there is an outstanding request
		if(this.request != null){
			this.request.abort();
		}
		
				//url substitutions
		var keyword = this.product;
   	keyword = keyword.replace(/\+/g, "%2B").replace(/&/g, '%26').replace(/\?/g, '%3F').replace(/=/g, '%3D').replace(/\s/,"%20").replace(/'/,""); 
		
		var aurl = "http://www.amazon.com/exec/obidos/external-search?mode=blended&keyword=" + keyword;
		// Setup Request	
		this.request	= new XMLHttpRequest();
		this.request.open("GET", aurl, true); //(default)true:async - false: sync
		this.request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		this.request.setRequestHeader("User-Agent", navigator.userAgent);

		
      	
		
		//store reference to stuff
		var handle = this;

		//alert('apr 46');
		// Handle request
		this.request.onload = {
			handleEvent : function(e){
				
				// If already aborted
				if(handle.request == null){
					return;
				}
				
				//get html from response and look for tunyurl
				var html = handle.request.responseText;
				handle.amazonPriceResult = null;
				//alert('amazon response ' + html);

						
//works091307-1				var _amzResultRegExStr ="<td class=\"priceBlockWithTopPadding\">\\s*<span class=\"priceType\">\\s*<a href=\"([^\"'\\s>]*)\">\\s*[a-z0-9\\s]*<\\/a>[:]\\s*<\\/span>\\s*[^\"'<]*<span class=\"(sr_price|saleprice)\">(\\$\\d+(?:\\.\\d{0,2})?)<\\/span>";
//works091307-2				var _amzResultRegExStr ="<td class=\"priceBlockWithTopPadding\">\\s*<span class=\"priceType\">\\s*<a href=\"([^\"'\\s>]*)\">\\s*[a-z0-9\\s]*<\\/a>[:]\\s*<\\/span>\\s*[^\"'<]*<span class=\"(sr_price|saleprice)\">(\\$\\d+(?:\\.\\d{0,2})?( - \\$\\d+(?:\\.\\d{0,2})?)?)<\\/span>";
				
//work091307-3				var _amzResultRegExStr ="<td class=\"priceBlockWithTopPadding\">\\s*<span class=\"priceType\">\\s*<a href=\"([^\"'\\s>]*)\">\\s*[a-z0-9\\s]*<\\/a>[:]\\s*<\\/span>\\s*[^\"'<]*<span class=\"(listprice|sr_price|saleprice)\">(\\$\\d+(?:\\.\\d{0,2})?( - \\$\\d+(?:\\.\\d{0,2})?)?)<\\/span>(\\s*<span class=\"saleprice\">(\\$\\d+(?:\\.\\d{0,2})?( - \\$\\d+(?:\\.\\d{0,2})?)?)<\\/span>)?";
var _amzResultRegExStr ="<td class=\"priceBlockWithTopPadding\">\\s*<span class=\"priceType\">\\s*<a href=\"([^\"'\\s>]*)\">\\s*[a-z0-9\\s]*<\\/a>[:]\\s*<\\/span>\\s*[^\"'<]*(\\s*<span class=\"listprice\">(\\$\\d+(?:\\.\\d{0,2})?( - \\$\\d+(?:\\.\\d{0,2})?)?)<\\/span>)?\\s*<span class=\"(sr_price|saleprice)\">(\\$\\d+(?:\\.\\d{0,2})?( - \\$\\d+(?:\\.\\d{0,2})?)?)<\\/span>";
	//var _amzResultRegExStr="<td class=\"dataColumn\">";
				var regexp	= new RegExp(_amzResultRegExStr, "ig");
				//var azresult	= regexp.exec(html);
				var azresult = null;
				handle.amazonInfoList = new Array();
				//azresult = regexp.exec(html);
				//alert('none loop execute azresult 1: ' + azresult[1] + ' 2: ' + azresult[2] + ' 3: ' + azresult[3]);
				//alert('none loop execute azresult 1: ' + azresult);
				//*1 - product link (useful)
				//2 - may be null
				//*3 - list price (optional) - may be null
				//4 - may be null
				//5 - sr_price or saleprice text
				//*6 - product price  (useful)
				while ((azresult = regexp.exec(html)) != null) {
					//alert('while azresult ' + azresult[1] + ', ' + azresult[2] + ', ' + azresult[3] + ', ' + azresult[4] + ', ' + azresult[5]+ ', ' + azresult[6]);
					var api = new SwakAmazonProductInfo();
					api.prodURL = azresult[1];
					api.prodPrice = azresult[6];
					handle.amazonInfoList.push(api);
				}
				/*
				if(azresult != null && azresult.length > 0){
					alert('result at 0 ' + azresult[1])
					handle.amazonPriceResult = azresult[1];  				
				}
				*/

				
				// callback to onerror or ondone
				if(handle.amazonInfoList == null || handle.amazonInfoList.length == 0){
					callback.onerror(handle);
				}
				else{
					//should just be sending back the tunyurl as a string
					callback.ondone(handle);
				}
			}
		};
		
		// check if the xmlhttprequest had an error--if so, callback to error
		this.request.onerror = {
			handleEvent : function(e){
				callback.onerror(handle);
			}
		}
       	      	
    //send request
    this.request.send(null);
	}
	

//cancel the request
	this.cancel = function(){
		try{
			this.request.abort();
		}catch(e){  }
	}	
}
*/